package com.atguigu.ssyx.acl.service.impl;

import com.atguigu.ssyx.acl.mapper.AdminMapper;
import com.atguigu.ssyx.acl.service.AdminService;
import com.atguigu.ssyx.model.acl.Admin;
import com.atguigu.ssyx.vo.acl.AdminQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author ZhangYK
 * @version 8.0
 * @title AdminServiceImpl
 * @description
 * @create 2024/7/5 20:52
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {


    /**
     * 用户分页查询
     * @param adminPage
     * @param adminQueryVo
     * @return
     */
    @Override
    public IPage<Admin> selectPageUser(Page<Admin> adminPage, AdminQueryVo adminQueryVo) {
        String username = adminQueryVo.getUsername();
        String name = adminQueryVo.getName();
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(username)){
            queryWrapper.like("username", username);
        }
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like("name", name);
        }
        Page<Admin> adminPage1 = baseMapper.selectPage(adminPage, queryWrapper);
        return adminPage1;
    }
}
